//
//  LJYBaseViewController.swift
//  新浪微博25
//
//  Created by 李俊扬 on 2017/6/30.
//  Copyright © 2017年 李俊扬. All rights reserved.
//

import UIKit

class LJYBaseViewController: UIViewController {
    
    // 判断是否登陆
    let isLogin: Bool = false
    // 全局访客视图
    var visitorView: LJYVisitorView?
    
    override func loadView() {
        if !isLogin {
            setupVisitorView()
        } else {
            
            super.loadView()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNav()
    }
    
    // 监听事件
    func loginClick() {
        print("点击了按钮")
    }
    
    // 设置访客视图View
    private func setupVisitorView() {
        
        visitorView = LJYVisitorView()
        
        visitorView?.closure = {[weak self] in
            // 04执行闭包
            self?.loginClick()
        }
        view = visitorView
        setupNav()
    }
    
    // 设置导航栏
    private func setupNav() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(imgName: nil, title: "注册", target: self, action: #selector(loginClick))
         navigationItem.rightBarButtonItem = UIBarButtonItem(imgName: nil, title: "登陆", target: self, action: #selector(loginClick))
    }

}
